package com.jacob.firstdemo;

/**
 * @auther jacob
 * @Date 2020/12/5 22:28
 */
public class Largest {

    /**
     * 查询 list 中最大值
     * @param list
     * @return list最大值
     */
    public static int largest(int[] list) {
        if (list.length == 0){
            throw new RuntimeException("Empty list");
        }

        int max = Integer.MIN_VALUE;
        for (int i = 0; i <= list.length - 1; i++) {
            if (list[i] > max) {
                max = list[i];
            }
        }
        return max;
    }
}
